/*
   BooyoPOSConst.h
   
   Copyright (C) 2006 LinuxOne, Inc. <Republic of korea>

   This library is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as
   published by the Free Software Foundation; either version 2.1
   of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   Lessor General Public License for more details.

   You should have received a copy of the GNU Lessor General Public
   License along with this library; if not, write to the Free Software
   Foundation, inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

   Hyunjin Kim <mgc521@linuxone.co.kr>

   LinuxOne, Inc., hereby disclaims all copylight
   written by Hyunjin Kim, 20 December 2006
*/

#ifndef _BOOYO_POS_BOOYOPOSCONST_H_
#define _BOOYO_POS_BOOYOPOSCONST_H_

#include <iostream>
#include <string>
#include <exception>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <termios.h>
#include <usb.h>

#include "RS232Const.h"

namespace booyopos
{

//#######################################################################
//#### General BooyoPOS Constants
//#######################################################################

class CBooyoPOSConst : public CRS232Const
{
public:
	enum State		// Holds the current state of the Device
	{
		S_CLOSED,
		S_IDLE,
		S_BUSY,
		S_ERROR
	};

	enum ErrorCode
	{
		ERR					= 100,
		ERREXT				= 200,

		SUCCESS				= 0,
		E_CLOSED			= 1 + ERR,
		E_CLAIMED			= 2 + ERR,
		E_NOTCLAIMED		= 3 + ERR,
		E_NOSERVICE			= 4 + ERR,
		E_DISABLED			= 5 + ERR,
		E_ILLEGAL			= 6 + ERR,
		E_NOHARDWARE		= 7 + ERR,
		E_OFFLINE			= 8 + ERR,
		E_NOEXIST			= 9 + ERR,
		E_EXIST				= 10 + ERR,
		E_FAILURE			= 11 + ERR,
		E_TIMEOUT			= 12 + ERR,
		E_BUSY				= 13 + ERR,
		E_EXTENDED			= 14 + ERR
	};

	enum ErrorCodeExtended
	{
		ESTATS_ERROR=280,
		EFIRMWARE_BAD_FILE,
		ESTATS_DEPENDENCY
	};

	enum BinaryConversion
	{
		BC_NONE,
		BC_NIBBLE,
		BC_DECIMAL
	};

	enum CheckHealthLevel	// Indicates the type of health check to be performed on the device
	{
		CH_INTERNAL,
		CH_EXTERNAL,
		CH_INTERACTIVE
	};

	enum CapPowerRepoting // Identifies the reporting capabilities of the Device
	{
		PR_NONE,
		PR_STANDARD,
		PR_ADVANCED
	};

	enum PowerNotify // Contains the type of power notification selection made by the Application.
	{
		PN_DISABLED,
		PN_ENABLED
	};

	enum PowerState // Identifies the current power condition of the device, if it can be determined
	{
		PS_UNKNOWN,
		PS_ONLINE,
		PS_OFF,
		PS_OFFLINE,
		PS_OFF_OFFLINE
	};

	enum CompareFirmwareVersionResult // Location in which to return the result of the comparison
	{
		CFV_FIRMWARE_OLDER,
		CFV_FIRMWARE_SAME,
		CFV_FIRMWARE_NEWER,
		CFV_FIRMWARE_DIFFERENT,
		CFV_FIRMWARE_UNKNOWN
	};

	//#######################################################################
	//#### General Event Handler Constants
	//#######################################################################

	enum ErrorLocus
	{
		/* Error occurred while processing asynchronous output */
		EL_OUTPUT,
		/* Error occurred while gathering or processing event driven input.
		   No previously buffered input data is available. */
		EL_INPUT, 
		/* Error occurred while gathering or processing event driven input, and
		   some previously buffered data is avilable. */
		EL_INPUT_DATA
	};

	enum ErrorResponse
	{
		/* This response directs the Device to retry the input. The error state is exited,
		   and State is changed to S_IDLE */
		ER_RETRY,
		/* Clear the buffered DataEvents and ErrorEvents and exit the error state, changing State to
		   S_IDLE.
		   This is the default response for locus EL_INPUT */
		ER_CLEAR,
		/* This response acknowledges the error and directs the Device to continue processing.
		   The Device remains in the error state, and will deliver additional data events as
		   directed by the DataEventEnabled property. When all input has been delivered and the
		   DataEventEnabled property is again set to true, another ErrorEvent is delivered with
		   locus EL_INPUT */
		ER_CONTINUEINPUT
	};

	enum StatusUpdateEventStatus
	{
		/* The device is powered on and ready for use. Can be returned if CapPowerReporting =
		   PR_STANDARD or PR_ADVANCED. */
		SUE_POWER_ONLINE=2001,
		/* The device is off or detached from the terminal. Can only be returned if
		   CapPowerRepoting = PR_ADVANCED. */
		SUE_POWER_OFF,
		/* The device is powered on but is either not ready or not able to respond to requests.
		   Can only be returned if CapPowerReporting = PR_STANDARD. */
		SUE_POWER_OFFLINE,
		/* The device is either off or offline. Can only be returned if CapPowerRepoting = 
		   PR_STANDARD. */
		SUE_POWER_OFF_OFFLINE,

		/* The update firmware process has successfully completed 1 to 100 percent of the total operation. */
		SUE_UF_PROGRESS=2100,
		/* The update firmware process has completed successfully. The value of this constant
		   is identical to SUE_UF_PROGRESS + 100. */
		SUE_UF_COMPLETE=2200,
		/* The update firmware process failed but the device is still operational. */
		SUE_UF_FAILED_DEV_OK,
		/* The update firmware process failed and the device is neither usable nor recoverable through
		   software. The device requires sercie to be returned to an operational state. */
		SUE_UF_FAILED_DEV_UNRECOVERABLE,
		/* The update firmware process failed and the device will not be operational until another
		   attempt to update the firmware is successful. */
		SUE_UF_FAILED_DEV_NEEDS_FIRMWARE,
		/* The update firmware process failed and the device is in an indeterminate state. */
		SUE_UF_FAILED_DEV_UNKNOWN,
		/* The update firmware process succeeded, however the Service and/or the physical device
		   cannot be returned to the state they were in before the update firmware process started.
		   The Service has restored all properties to their default initialization values. */
		SUE_UF_COMPLETE_DEV_NOT_RESTORED
	};

	/* Temp */
	typedef int EventCallbacks;
};

} // namespace booyopos

#endif // _BOOYO_POS_BOOYOPOSCONST_H_
